import pandas as pd
import os
from tqdm import tqdm
import warnings

warnings.filterwarnings('ignore')
train_path = '../input/hy_round1_train_20200102'
test_path = '../input/hy_round1_testA_20200102'

train_files = os.listdir(train_path)
test_files = os.listdir(test_path)
print(len(train_files), len(test_files))
# %%
train_files[:3]
test_files[:3]
# %%
df = pd.read_csv(f'{train_path}/6966.csv')
df.head(100)
df['type'].unique()
df.shape

# %%
ret = []
for file in tqdm(train_files):
    df = pd.read_csv(f'{train_path}/{file}')
    ret.append(df)
df = pd.concat(ret)
df.columns = ['ship', 'x', 'y', 'v', 'd', 'time', 'type']
df.to_hdf('../input/train.h5', 'df', mode='w')

# %%
ret = []
for file in tqdm(test_files):
    df = pd.read_csv(f'{test_path}/{file}')
    ret.append(df)
df = pd.concat(ret)
df.columns = ['ship', 'x', 'y', 'v', 'd', 'time']
df.to_hdf('../input/test.h5', 'df', mode='w')
